import java.util.Arrays;
import java.util.Random;

public class Test {
    public static void initOrder(int[] array) {
        for(int i = 0;i<array.length;i++) {
            array[i] = i;
        }
    }

    public static void notOrder(int[] array) {
        Random random = new Random();
        for(int i = 0;i<array.length;i++) {
            array[i] = random.nextInt(100000);
        }
    }
    public static void main(String[] args) {
        int[] array = new int[10_0000];
        initOrder(array);
        testInsert(array);
        testQuick(array);
        testQuickNonR(array);
    }

    public static void testInsert(int[] array) {
        int[] tmpArray = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.insertSort(tmpArray,0,tmpArray.length-1);
        long endTime = System.currentTimeMillis();
        System.out.println("插入排序耗时："+(endTime-startTime));
        //System.out.println(Arrays.toString(tmpArray));
    }

    public static void testQuickNonR(int[] array) {
        int[] tmpArray = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSortNonR(tmpArray,0,tmpArray.length-1);
        long endTime = System.currentTimeMillis();
        System.out.println("非递归快排序耗时："+(endTime-startTime));
        //System.out.println(Arrays.toString(tmpArray));
    }

    public static void testQuick(int[] array) {
        int[] tmpArray = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSort(tmpArray,0,tmpArray.length-1);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时："+(endTime-startTime));
        //System.out.println(Arrays.toString(tmpArray));
    }

//    public static void main1(String[] args) {
//        Sort sort = new Sort();
//        int [] array = {3,4,2,5,1,6};
//        sort.quickSortNonR(array,0,array.length-1);
//        System.out.println(Arrays.toString(array));
//    }
}
